package com.ark.cloud.javacallnative.modules.storage.service.impl;

import com.ark.cloud.javacallnative.entity.EntityType;
import com.ark.cloud.javacallnative.entity.FireDNEvent;
import com.ark.cloud.javacallnative.modules.storage.mapper.EntityTypeMapper;
import com.ark.cloud.javacallnative.modules.storage.mapper.FireDNEventMapper;
import com.ark.cloud.javacallnative.modules.storage.service.FireDNEventService;
import com.ark.cloud.javacallnative.util.UUIDUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FireDNEventServiceImpl extends ServiceImpl<FireDNEventMapper, FireDNEvent> implements FireDNEventService {


    @Autowired
    EntityTypeMapper entityTypeDao;

    @Autowired
    private FireDNEventMapper fireDNEventMapper;


    @Override
    public void saveFireDNEvent(FireDNEvent fireDNEvent) {
        // entity_type表插入
        EntityType entityType = fireDNEvent.getMunitionType();

//        随机生成ID
        entityType.setId(UUIDUtil.next());

        entityTypeDao.insert(entityType);

        Long typeId = entityType.getId();

        fireDNEvent.setId(UUIDUtil.next());
        fireDNEvent.setMunitionTypeId(typeId);
        fireDNEventMapper.insert(fireDNEvent);

    }
}
